home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / Conic Sections 0.9.2 / Sources / ConicViewManager.cpp < prev    next >
Encoding:
Text File  |  1997-06-14  |  2.1 KB  |  86 lines  |  [TEXT/CWIE]

  1. //Copyright (c) 1997 Aidan Cully
  2. //All rights reserved
  3.  
  4. #include "ConicViewManager.h"
  5. #include "Messages.h"
  6.  
  7. TViewManagerHolder::TViewManagerHolder( TLayoutBranch *super, TConic *conic, TPlane *plane ):
  8.     TLayoutBranch( super )
  9. {
  10.     mConic= conic;
  11.     mPlane= plane;
  12. }
  13.  
  14. void TViewManagerHolder::BuildChildren()
  15. {
  16.     TConicViewManager *child;
  17.     Rect contRect= mContentRect;
  18.     contRect.right= 40;
  19.     Boolean bind[4];
  20.     bind[0]= true;
  21.     bind[1]= true;
  22.     bind[2]= false;
  23.     bind[3]= false;
  24.     for( int temp=kOrientationPlaneClockwise; temp<=kOrientationPlaneOut; temp++ ) {
  25.         child= new TConicViewManager( this, 1000+temp, mConic, mPlane, temp );
  26.         child->Init();
  27.         AddChild( child, contRect, bind );
  28.         ::OffsetRect( &contRect, 40, 0 );
  29.     }
  30. }
  31.  
  32. TConicViewManager::TConicViewManager( TLayoutBranch *super, SInt16 resID,  TConic *conic,
  33.  TPlane *plane, int orientation ):
  34.     TPicControl( super, resID )
  35. {
  36.     mConic = conic;
  37.     mPlane = plane;
  38.     mOrientation = orientation;
  39. }
  40.  
  41. void TConicViewManager::TrackMouseWithin( TMouseEvent *event )
  42. {
  43.     int timeDis= event->when-mPrevTime;
  44.     mPrevTime= event->when;
  45.  
  46.     switch( mOrientation ) {
  47.     case kOrientationPlaneClockwise:
  48.         mPlane->SetAngle( mPlane->GetAngle()-timeDis );
  49.         mConic->CalcIntersect( *mPlane );
  50.         mPlane->SendMessage( (UINT32)kUpdateWindow );
  51.         break;
  52.     case kOrientationPlaneCounter:
  53.         mPlane->SetAngle( mPlane->GetAngle()+timeDis );
  54.         mConic->CalcIntersect( *mPlane );
  55.         mPlane->SendMessage( (UINT32)kUpdateWindow );
  56.         break;
  57.     case kOrientationPlaneIn:
  58.         mPlane->SetDistance( mPlane->GetDistance()-timeDis/32.0 );
  59.         mConic->CalcIntersect( *mPlane );
  60.         mPlane->SendMessage( (UINT32)kUpdateWindow );
  61.         break;
  62.     case kOrientationPlaneOut:
  63.         mPlane->SetDistance( mPlane->GetDistance()+timeDis/32.0 );
  64.         mConic->CalcIntersect( *mPlane );
  65.         mPlane->SendMessage( (UINT32)kUpdateWindow );
  66.         break;
  67.     default:
  68.         return;
  69.     }
  70. }
  71.  
  72. void TConicViewManager::TrackMouseChange( TMouseEvent *event, Boolean inside )
  73. {
  74.     if( inside )
  75.         mPrevTime= event->when;
  76.     else
  77.         mPrevTime= 0;
  78.     TPicControl::TrackMouseChange( event, inside );
  79. }
  80.  
  81. void TConicViewManager::TrackMouseDown( TMouseEvent *event )
  82. {
  83.     mPrevTime= event->when-1;
  84.     TPicControl::TrackMouseDown( event );
  85.     TrackMouseWithin( event );
  86. }